<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-wcs__logwork}">
      <div class="ba-operate-form">
        <el-form :model="dataForm" @keyup.enter.native="getDataList()" label-width="70px">
          <el-row :gutter="5">
            <el-col :md="8" :sm="8">
              <el-form-item label="关联码">
                <el-input v-model="dataForm.contNo" placeholder="可输入料架码-PK或任务单" maxlength="32" clearable></el-input>
              </el-form-item>
            </el-col>
            <el-col :md="10" :sm="8">
              <el-form-item label="时间">
                <el-date-picker v-model="dateRange" value-format="yyyy-MM-dd HH:mm:ss" type="datetimerange"
                  range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :md="6" :sm="8">
              <div class="right-handle-group">
                <el-button-group>
                  <el-button @click="getDataList()" type="primary">{{
                    $t("query")
                  }}</el-button>
                  <el-button @click="getReset()">{{ $t("reset") }}</el-button>
                  <el-button @click="advanced = !advanced" color="#dcdfe6" icon="el-icon-search" plain></el-button>
                </el-button-group>
              </div>
            </el-col>
          </el-row>
        </el-form>
      </div>

      <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle"
        style="width: 100%">
        <el-table-column prop="id" label="id" header-align="center" align="center"></el-table-column>
        <el-table-column prop="createDate" label="生成时间" header-align="center" align="center"
          min-width="160"></el-table-column>
          <el-table-column prop="workName" label="作业流程" header-align="center" align="left"
          min-width="155"></el-table-column>
        <el-table-column prop="contNo" label="料箱码" header-align="center" align="center" min-width="110"
          show-overflow-tooltip></el-table-column>
        <el-table-column prop="workCode" label="结果码" header-align="center" align="center" show-overflow-tooltip></el-table-column>
        <el-table-column prop="workMsg" label="作业详情" header-align="center" align="left" min-width="520"
          show-overflow-tooltip></el-table-column>
        <el-table-column prop="workProc" label="相关过程" header-align="center" align="left"
          min-width="250"></el-table-column>
        <el-table-column prop="workSec" label="耗时/ms" header-align="center" align="center"></el-table-column>
        <el-table-column prop="creatorName" label="用户名称" header-align="center" align="center" show-overflow-tooltip></el-table-column>
      </el-table>
      <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
        layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle">
      </el-pagination>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from "@/mixins/view-module";
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: "/sys/log-work/page",
        getDataListIsPage: true,
      },
      dataForm: {
        contNo: "",
        workMsg: "",
        workProc: "",
        startDate: "",
        endDate: "",
      },
      pickerOptions: {
        shortcuts: [
          {
            text: "当天",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setHours(0, 0, 0);

              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
      advanced: false, //高级搜索
    };
  },
  methods: {
    //0.重置搜索框
    getReset() {
      this.dataForm = this.$options.data().dataForm;
      this.dateRange = this.$options.data().dateRange;
    },
  },
};
</script>
<style>
.el-row {
  margin-bottom: 0px;
}

.right-handle-group {
  float: right;
}
</style>